<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'creatAccount.jsp' starting page</title>
    <script type="text/javascript" src="js/jquery.js"></script>
    <style type="text/css">
    	span{
    		color:red;
    	}
    </style>
  </head>
  
  <body>
  	<h3>网上开户</h3>
  	<form action="create.jspx" method = "post"id="myform">
		Username:<input type="text" name="username" id="username" /><span id="name_error"></span><br />
		Password:<input type="password" name="password" id="password" /><span id="pwd_error"></span><br />
		Money:<input type="text" name="money" id="firstMoney" /><span id="money_error"></span><br />
		<input type="button" value="提交"id="btn" />
	</form>
	
	<script type="text/javascript">
		$(document).ready(function(){
			$("#username").keydown(function(){
				$("#name_error").html("");
			});
			$("#password").keydown(function(){
				$("#pwd_error").html("");
			});
			$("#firstMoney").keydown(function(){
				$("#money_error").html("");
			});
			$("#btn").click(function(){
				var name = $("#username").val();
				var pwd = $("#password").val();
				var money = $("#firstMoney").val();
				if(name.trim()== ""){
					$("#username").focus();
					$("#name_error").html("请输入用户名，用户名只能由字母、数字、下划线组成：");
					return;
				}
				if(pwd == ""){
					$("#password").focus();
					$("#pwd_error").html("请输入密码，密码只能由字母、数字、下划线组成：");
					return;
				}
				if(money <= 0){
					$("#firstMoney").focus();
					$("#money_error").html("请输入正确金额,金额数目不可为负数：");
					return;
				}
				$("#myform").submit();
			});
		});
	</script>
  </body>
</html>
